package com.wk.kxexamadminister.controller;

import com.wk.kxexamadminister.entity.ClassTable;
import com.wk.kxexamadminister.entity.Institute;
import com.wk.kxexamadminister.entity.StudentExt;
import com.wk.kxexamadminister.entity.Teacher;
import com.wk.kxexamadminister.mapper.*;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Date;

@Controller
@ApiOperation("只负责携带参数跳转")
public class JumpController {

    @Autowired
    private StudentMapper studentMapper;
    @Autowired
    private ClassMapper classMapper;
    @Autowired
    private TeacherMapper teacherMapper;
    @Autowired
    private InstituteMapper instituteMapper;



    @RequestMapping("/toLogin")
    public String loginPage(){
        return "01-login";
    }

    @RequestMapping("/toAdd")
    public String toAdd(){
        return "addStudent";
    }

    @RequestMapping("/toMain")
    public String toButtonHome(){
        return "02-main";
    }

    @RequestMapping("/toUpLoad")
    public String toUpLoad(){
        return "00-upload";
    }



    @GetMapping("/toStudentUpd")
    public String toStudentUpd(Model model,Integer sNum){
        StudentExt studentExt = studentMapper.findById(sNum);
        model.addAttribute("student",studentExt);
        return "14-updateStudent";
    }
    @GetMapping("/toTeacherUpd")
    public String toTeacherUpd(Model model,Integer tId){
        Teacher teacher = teacherMapper.selectById(tId);
        model.addAttribute("teacher",teacher);
        return "08-updateTeacher";
    }
    @GetMapping("/toClassUpd")
    public String toClassUpd(Model model,Integer cId){
        ClassTable classTable = classMapper.selectById(cId);
        model.addAttribute("classTable",classTable);
        return "11-updateClassz";
    }
    @GetMapping("/toInstituteUpd")
    public String toInstituteUpd(Model model,Integer iId){
        Institute institute = instituteMapper.selectById(iId);
        model.addAttribute("institute",institute);
        return "05-updateCollgeInfo";
    }

    @RequestMapping("/toAddStudent")
    public String toAddStudent(){
        return "12-addStudent";
    }
    @RequestMapping("/toAddInstitute")
    public String toAddInstitute(){
        return "03-addCollge";
    }
    @RequestMapping("/toAddTeacher")
    public String toAddTeacher(){
        return "06-addTeacher";
    }
    @RequestMapping("/toAddClass")
    public String toAddClass(){
        return "09-addClassz";
    }



}
